//
//  UserdsltView.m
//  MoXiProject
//
//  Created by 周筱雯 on 2017/6/29.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "UserdsltView.h"
#import "UserDSInfoCell.h"
#import "UserInfoModel.h"


@interface UserdsltView ()
<
    UITableViewDelegate,
    UITableViewDataSource
>
@property (nonatomic,strong) UIView * tempView;

@property (nonatomic,strong) UserInfoModel * infoModel;
@end

@implementation UserdsltView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.delegate = self;
        self.dataSource = self;
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        [MXUtility setExtraCellLineHidde:self tabHeader:NO tabFooter:NO];
        
        [self createTempView];
    }
    
    return self;
}
-(void)setUserModel:(UserInfoModel *)userModel
{
    self.infoModel = userModel;
    [self reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * str = @"cell";
    
    UserDSInfoCell * cell = [tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"UserDSInfoCell" owner:self options:nil] lastObject];
    }
    [cell.usermz setText:[NSString stringWithFormat:@"%.2f%%",[self.infoModel.userinfohitRate floatValue]]];
    [cell.useryl setText:[NSString stringWithFormat:@"%.2f%%",[self.infoModel.userinfoearnRate floatValue]]];
    [cell.userjf setText:self.infoModel.userinfoscore];

    
    return cell;
}

-(void)createTempView{
    self.tempView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,self.width, self.height)];
    
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake((CGRectGetWidth(self.tempView.frame) - 50)/2, (CGRectGetHeight(self.tempView.frame) - 154)/2, 50, 50)];
    imageview.image = [UIImage imageNamed:@"wushuju"];
    imageview.contentMode = UIViewContentModeScaleAspectFit;
    [self.tempView addSubview:imageview];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0,imageview.height+10 + imageview.y, CGRectGetWidth(self.tempView.frame), 30)];
    label.textColor = DEF_COLOR_RGB(215, 215, 215);
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:15.f];
    label.text = @"暂无大神擂台数据";
    [self.tempView addSubview:label];
    
    [self addSubview:self.tempView];
    self.tempView.hidden = YES;
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
